package cn.sskxyz.security.resource.config;


import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.vote.AffirmativeBased;
import org.springframework.security.config.annotation.ObjectPostProcessor;

import java.util.List;

public class ResourcePostProcessor implements ObjectPostProcessor<AffirmativeBased> {

    private AccessDecisionVoter[] decisionVoter;

    public ResourcePostProcessor(AccessDecisionVoter... decisionVoter) {
        this.decisionVoter = decisionVoter;
    }

    @Override
    public AffirmativeBased postProcess(AffirmativeBased accessDecisionManager) {
        List<AccessDecisionVoter<? extends Object>> decisionVoterList = accessDecisionManager.getDecisionVoters();
        for (int i = 0; i < decisionVoter.length; i++) {
            decisionVoterList.add(decisionVoter[i]);
        }
        return accessDecisionManager;
    }
}
